<?php
require_once("lib/db_connection.php");
$veh_id = $_GET['veh_id'];
$date = $_GET['date'];
$trouble = $_GET['trouble'];
$query_dec = "UPDATE vehicle_tbl SET out_of_service='1' WHERE vehicle_id='".$veh_id."'";
mysql_query($query_dec) or die("DECOMMISSION FAILED ".mysql_error());

//TROUBLE
$result_trouble = mysql_query("select * from trouble_droplist_tbl where company_id = '".$_SESSION['company_id']."' and autoid = '".$trouble."'");
$row_trouble = mysql_fetch_array($result_trouble);

$result = mysql_query("insert into veh_decommission (company_id,
       veh_id,
       dec_date,
       reason)

       values ('".$_SESSION['company_id']."',
       '".$veh_id."',
       '".$date."',
       '".$row_trouble['value']."')")or die("INSERT VEHICLE DECOMMISSION - " . mysql_error());
?>